﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace RSSReader
{
    [XmlRoot("RSSIgnoreList", Namespace = "RSSIgnoreList", IsNullable = false)]
    public class RSSIgnoreList
    {
        public RSSIgnoreList()
        {
            IgnoreList = new List<string>();
        }
        
        public List<string> IgnoreList { get; set; }
        public void SetFromString(string ignoreList)
        {
            string[] items = ignoreList.Split(new char[]{','}, StringSplitOptions.RemoveEmptyEntries);
            IgnoreList.Clear();
            foreach (string item in items)
            {
                IgnoreList.Add(item.Trim());
            }
        }

        public override string ToString()
        {
            string s = "";
            if (IgnoreList.Count < 1)
                return s;

            foreach (string item in IgnoreList)
            {
                s += item + ",";
            }
            return s.Substring(0, s.Length - 1);
        }
    }
}
